package triangle;

import java.util.Scanner;

public class Triangle_Carl {
	
	public static void main (String[] args) {
		Scanner input;
		double side1;
		double side2;
		double side3;
		String TriangleType;
		String retry = "Y";
		input = new Scanner(System.in);
		try {
			while (retry.equals("Y") | retry.equals("y")){
					System.out.println("This program will classify a triangle based on the "
							+"inputs of 3 side lengths.");
					System.out.println("Please enter length of Side 1 : ");
					 side1 = input.nextDouble(); // getting value of Side1
		
					 System.out.println("Please enter length of Side 2 : ");
					 side2 = input.nextDouble(); // getting value of Side2
		
					 System.out.println("Please enter length of Side 3 : ");
					 side3 = input.nextDouble(); // getting value of Side3
				
					if (side1+side2>side3 && side2+side3>side1 && side1+side3>side2){
						if (Double.compare(side1,side2)==0 && 
								Double.compare(side2,side3)==0){
							TriangleType = "Equilateral";
						} else if (Double.compare(side1,side2)==0 | 
								Double.compare(side2,side3)==0 | 
								Double.compare(side1,side3)==0){
							TriangleType = "Isosceles";
						} else{
							TriangleType = "Scalene";
						}
						if (side1*side1+side2*side2==side3*side3 | 
							side2*side2+side3*side3==side1*side1 | 
							side1*side1+side3*side3==side2*side2){
							System.out.println("You have defined a Right "+TriangleType+" triangle.");
						} else System.out.println("You have defined a non-right "+TriangleType+" triangle.");
					
					} else {System.out.println("The side lengths entered don't make a triangle.");
					}
	
				 System.out.println("Would you like to define another triangle? (Y/N)");
				 retry = input.next(); // getting retry command	
			}
		} finally {
			input.close();
		}
	}

}
